package com.yy.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.yy.service.ProviderHystrixService;
import com.yy.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Author young
 * Date 2022/12/25 17:21
 * Description: 通配后的hyxtri降级配置接口，进一步解耦
 * 存在问题：好像不支持超时问题，仍然异常出现
 */
@Slf4j
@RestController
@RequestMapping("best")
public class UsuallyHystrixController {
    @Resource
    private ProviderHystrixService providerHystrixService;

    @GetMapping("/test/ok/{id}")
    public Result<String> providerOk(@PathVariable("id") Integer id){
        return providerHystrixService.selectOne(id);
    }

    
   
    @GetMapping("/test/wait/{id}")
    public Result<String> providerWait(@PathVariable("id") Integer id){
        return providerHystrixService.selectOneWait(id);
    }

    @GetMapping("ee")
    public Result<String> er(){
        int a = 10/0;
        return  Result.ok("不行");
    }
}
